import asyncio

# # 定义协程函数
# async def greet():
#     print("hello, ")
#     await asyncio.sleep(1)  # 模拟异步操作，暂停1秒
#     print("world!")

# ==============================================================
# 定义第一个异步函数
async def say_hello():
    print("hello!")
    await asyncio.sleep(1)
    print("done saying hello.",end='\n')

# 定义第二个异步函数
async def say_goodbye():
    print("goodbye!")
    await asyncio.sleep(2)
    print("done saying goodbye.")

# 定义主协程函数并发运行多个异步函数
async def main():
    await asyncio.gather(say_hello(), say_goodbye())

asyncio.run(main())


if __name__ == '__main__':
    # # 使用asyncio.run运行协程
    # asyncio.run(greet())
    asyncio.run(main())